<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.ArrayList" %>
<%@ page import="com.net.test.vo.TVO" %>
<script>
function go_edit(){
	var frm = document.viewFrm;
	frm.action = "/tboardEdit.ncb";
	frm.submit();	
}
function go_delete(){
	var frm = document.viewFrm;
	 if(!confirm("삭제하시겠습니까?"))return;
	    frm.action = "/tboardDel.ncb";
	    frm.submit(); 
}

function go_like(){
	var frm = document.viewFrm;
	 if(!confirm("좋으심?"))return;
	 alert("추천됨");
	 frm.action = "/likeUpdate.ncb";
	 frm.submit(); 
}
function go_down(){
	var frm = document.viewFrm;
	 if(!confirm("다운ok?"))return;
	 frm.action = "/downLoad.ncb";
	 frm.submit(); 
}

</script>
<%
	HttpSession sessions = request.getSession();
	String login_id = (String)sessions.getAttribute("login_id");

  	String result = request.getAttribute("result") == null ? "" :(String)request.getAttribute("result");  
  	if(result.equals("1")){
  %>
  <script>
  	alert("삭제됨");
  	location.href ="/tlogView.ncb";
  
  </script>
  
  <%
  }else if(!result.equals("") && !result.equals("1")){
  %>
  <script>
   alert("에러");
   
  </script>
  <%} %>
  
  
<%
	TVO view = (TVO)request.getAttribute("view");  	
		String title = "";
		String contents = "";
		String new_name = "";
		String org_name = "";
		String seq = "";
		String id = "";
		
	if(view != null){
		title = view.getTitle() == null ? "" : view.getTitle();
		contents = view.getContents() == null ? "" : view.getContents();
		new_name = view.getNew_name() == null ? "" : view.getNew_name();
		org_name = view.getOrg_name() == null ? "" : view.getOrg_name();
		seq = view.getSeq() == null? "" : view.getSeq();
		id = view.getId() == null? "" : view.getId();
	}
%>

<br />
<h1>게시판 상세보기</h1> 
<br />

<form name="viewFrm" method="POST" >
	<input type="hidden" name="seq"  value="<%=seq %>">
	
	
    <table width="90%" cellpadding="5" cellspacing="0" border="1" style="border-collapse:collapse; border:1px gray solid;">
        <tr>
            <td width="30%" align="center">제목</td>
            <td width="50%" align="center">내용</td>
        </tr>
        
        
        
       
        <tr>
            <td width="30%" align="center"><%=title%></td>
            <td width="50%" align="center"><%=contents%><br />
            
            <%
            if(!new_name.equals("")){
            %>
            <img alt="" src="/upload/<%=new_name %>">
            <%
            }
            %>	
            
            </td>
        </tr>
        
    </table>
</form>
    
    <%if(login_id.equals(id)){ %>
    <input type="button" value="수정하기" onclick="javascript:go_edit();"/>    
    <input type="button" value="삭제하기" onclick="javascript:go_delete();"/>
    <%} %>
    <input type="button" value="좋아요" onclick="javascript: go_like();"/>
    <input type="button" value="목록보기" onclick="javascript:location.href='/tlogView.ncb'"/>
    <%
    if(!org_name.equals("")){
    %>
    <input type="button" value="<%=org_name %> 다운로드" onclick="javascript:go_down();"/>
    
    <%	
    }
    %>
